package objbo.xmlparser.controls.action;

import org.eclipse.jface.action.Action;

import objbo.xmlparser.controls.ControlMain;
import objbo.xmlparser.model.bean.ElementBean;
import objbo.xmlparser.view.interfaces.ElementInterFace;
import objbo.xmlparser.view.interfaces.UIInterFace;
import objbo.xmlparser.view.ui.ElementListUI;


public class ElementListRemoveAction extends Action
{
	private UIInterFace uIInterFace = null;
	private ElementInterFace elementInterFace = null;
	private ElementListUI ui = null;
	
	public ElementListRemoveAction(ElementInterFace elementInterFace, UIInterFace uIInterFace)
	{
		this.uIInterFace = uIInterFace;
		this.elementInterFace = elementInterFace;
	}
	
	public void setElementListUI(ElementListUI ui)
	{
		this.ui = ui;
	}
	
	
	@Override
	public void run()
	{
		Object[] data = ui.getdata();

		ElementBean elementBean = (ElementBean) data[0];
		//String name = (String) data[1];
		int index = (Integer) data[2];
		
		if(elementBean == null)
		{return;}
		
		this.elementInterFace.removeElement(elementBean, index);
		
		this.uIInterFace.setTabElementData(elementBean);
		this.uIInterFace.refreshTreeUI();
		
	}
}
